package 洛谷.二分答案;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.lang.*;
import  java.util.*;
public class test2 {
    static int[] q=new int[1000005];
    static int[] s=new int[1000005];

    public static void main(String[] args) {
        Reader1 sc = new Reader1();
        int n,m;
        n=sc.nextInt();
        m=sc.nextInt();


        for(int i=0;i<n;i++){
            q[i]=sc.nextInt();
            s[q[i]]++;
            q[i]-=m;
        }
        int res=0;
        for(int i=0;i<n;i++){
            if(q[i]>0)
                res+=s[q[i]];
        }

        System.out.println(res);
    }

}

class Reader1{
    public BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    public StreamTokenizer st=new StreamTokenizer(br);
    void Token(){
        try {
            st.nextToken();
        }catch (Exception e){

        }
    }

    public int nextInt(){
        Token();
        return (int)st.nval;
    }
}